@extends('backstage.layout.master')
@section('title', '填写不通过原因')
@section('content')
    <style>
        .state li {
            list-style: none;
            float: left;
            padding: 0 20px;
            text-align: center;
            height: 40px;
            line-height: 40px;
        }

        .state ul {
            margin: 0;
        }

        .state a {
            font-size: 12px;
        }

        .che a {
            font-weight: bold;
            color: #7c7c7c;
        }
    </style>
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a target="_blank" href="backstage/home">主页</a>
            </li>

            <li class="active">
                <a target="_blank" href="/backstage/source-pic/all">素材列表</a>
            </li>
        </ul><!-- .breadcrumb -->

    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        填写不通过原因
                        <span class="pull-right">
                         <button class="btn btn-primary" onclick="javascript:window.location.href='{{asset('')}}backstage/source-pic/all';">添加素材列表</button>
                        </span>
                    </h1>
                </div>

                    <div class="space-4"></div>
                    <div class="form-group" style="height:30px;margin-left: 23%;">
                            <p style="font-size: 15px;color: #2679b5">所填写的原因,将推送给用户</p>
                            <input class="source_pic_id" value="{{isset($source_pic_id)?$source_pic_id:''}}" type="hidden">
                            <textarea class="wysiwyg-editor notpassMsg" contenteditable="true" style="width: 63%"></textarea>
                    </div>
                <div style="height: 250px;"></div>
                    <div class="clearfix form-actions" style="height: 90px;">
                        <div class="col-md-4" style="margin-left: 45px;"></div>
                        <div class="col-md-7">
                            <button class="btn btn-info not-pass">
                                <i class="icon-ok bigger-110"></i>
                                确定
                            </button>

                            &nbsp; &nbsp; &nbsp;
                            @if(!empty($referer_url))
                            <button class="btn"
                               onclick="javascript:window.location.href='{{isset($referer_url)?$referer_url:'#'}}';"
                            >
                                <i class="icon-undo bigger-110"></i>
                                返回
                            </button>
                           @endif
                        </div>
                    </div>

                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
    <script type="text/javascript">
        $(function () {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $(".clearfix .not-pass").click(function () {
                var notpassMsg = $(".form-group .notpassMsg").val();
                var source_pic_id = $(".form-group .source_pic_id").val();
                swal({
                    title: "是否确定？",
                    text: "",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    closeOnConfirm: true,
                    closeOnCancel: true
                }, function () {
                    $.ajax({
                        type: "post",
                        url: "/backstage/source-pic/audit-not-pass",
                        data: {"source_pic_id": source_pic_id,
                            "Msg":notpassMsg
                        },
                        success: function (msg) {
                            if(msg.state==1){
                                swal({
                                    title: '保存成功',
                                    text: "",
                                    type: "success",
                                    timer:2000
                                });
                            }else {
                                swal({
                                    title: msg.message,
                                    text: "",
                                    type: "error",
                                    timer:3000
                                });
                            }
                        },
                        error: function () {
                            swal({
                                title: "系统繁忙！",
                                text: "",
                                type: "error",
                                timer:2000
                            });
                        }
                    });
                });
            });

        });

    </script>
@stop